/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.Entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author BachLe
 */
@Entity
@Table(name = "Payment")
@NamedQueries({
    @NamedQuery(name = "Payment.findAll", query = "SELECT p FROM Payment p"),
    @NamedQuery(name = "Payment.findByPaymentID", query = "SELECT p FROM Payment p WHERE p.paymentID = :paymentID"),
    @NamedQuery(name = "Payment.findByPaymentDateFinal", query = "SELECT p FROM Payment p WHERE p.paymentDateFinal = :paymentDateFinal"),
    @NamedQuery(name = "Payment.findByTotalAmount", query = "SELECT p FROM Payment p WHERE p.totalAmount = :totalAmount"),
    @NamedQuery(name = "Payment.findByDuePay", query = "SELECT p FROM Payment p WHERE p.duePay = :duePay"),
    @NamedQuery(name = "Payment.findByTypePay", query = "SELECT p FROM Payment p WHERE p.typePay = :typePay"),
    @NamedQuery(name = "Payment.findByStatusPay", query = "SELECT p FROM Payment p WHERE p.statusPay = :statusPay")})
public class Payment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "PaymentID")
    private Integer paymentID;
    @Basic(optional = false)
    @Column(name = "PaymentDateFinal")
    @Temporal(TemporalType.TIMESTAMP)
    private Date paymentDateFinal;
    @Basic(optional = false)
    @Column(name = "TotalAmount")
    private Integer totalAmount;
    @Column(name = "DuePay")
    private Integer duePay;
    @Basic(optional = false)
    @Column(name = "TypePay")
    private int typePay;
    @Column(name = "StatusPay")
    private Integer statusPay;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "payment")
    private List<PaymentDetails> paymentDetailsList;
    @JoinColumn(name = "OrderID", referencedColumnName = "OrderID")
    @ManyToOne(optional = false)
    private Orders orders;

    public Payment() {
    }

    public Payment(Integer paymentID) {
        this.paymentID = paymentID;
    }

    public Payment(Integer paymentID, Date paymentDateFinal, Integer totalAmount, int typePay) {
        this.paymentID = paymentID;
        this.paymentDateFinal = paymentDateFinal;
        this.totalAmount = totalAmount;
        this.typePay = typePay;
    }

    public Integer getPaymentID() {
        return paymentID;
    }

    public void setPaymentID(Integer paymentID) {
        this.paymentID = paymentID;
    }

    public Date getPaymentDateFinal() {
        return paymentDateFinal;
    }

    public void setPaymentDateFinal(Date paymentDateFinal) {
        this.paymentDateFinal = paymentDateFinal;
    }

    public Integer getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(Integer totalAmount) {
        this.totalAmount = totalAmount;
    }

    public Integer getDuePay() {
        return duePay;
    }

    public void setDuePay(Integer duePay) {
        this.duePay = duePay;
    }

    public int getTypePay() {
        return typePay;
    }

    public void setTypePay(int typePay) {
        this.typePay = typePay;
    }

    public Integer getStatusPay() {
        return statusPay;
    }

    public void setStatusPay(Integer statusPay) {
        this.statusPay = statusPay;
    }

    public List<PaymentDetails> getPaymentDetailsList() {
        return paymentDetailsList;
    }

    public void setPaymentDetailsList(List<PaymentDetails> paymentDetailsList) {
        this.paymentDetailsList = paymentDetailsList;
    }

    public Orders getOrders() {
        return orders;
    }

    public void setOrders(Orders orders) {
        this.orders = orders;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (paymentID != null ? paymentID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Payment)) {
            return false;
        }
        Payment other = (Payment) object;
        if ((this.paymentID == null && other.paymentID != null) || (this.paymentID != null && !this.paymentID.equals(other.paymentID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vn.ac.c0910g.assignment.DAO.Payment[paymentID=" + paymentID + "]";
    }

}
